<?php

class ActivityForm extends BaseForm {

    public function __construct($suffix = null) {
        $this->index = ($suffix) ? $suffix : '';
        parent::__construct();
    }

    public function setup() {
        $activities = $this->getActivitiesFormatted();

        $this->setWidgets(array(
            'activity_id'. $this->index => new sfWidgetFormChoice(array('choices' => $activities)),
            'activity_size'. $this->index => new sfWidgetFormInputText(),
        ));

        $this->setValidators(array(
            'activity_id'. $this->index => new sfValidatorChoice(array('choices' => array_keys($activities), 'required' => true), array('required' => 'Please enter required field.')),
            'activity_size'. $this->index => new sfValidatorNumber(array('required' => true), array('required' => 'Please enter required field.'))
        ));

        $this->widgetSchema->setNameFormat('activity[%s]');
    }
    
        private function getActivitiesFormatted() {
        $bank_accounts = Doctrine_Query::create()->from('Activity')->fetchArray();
        $result = array('' => '');

        foreach ($bank_accounts as $bank_account) {
            $result[$bank_account['id']] = $bank_account['activity_name'];
        }
        return $result;
    }

}

?>
